use crate::rating;
use crate::workflow;
use crate::workflow::*;
use crate::rating::*;
use crate::rule::*;

use std::collections::HashMap;
use std::fs::File;
use std::io::BufRead;

pub fn solution() {

}

fn parse_input() -> (HashMap<String, Workflow>, Vec<Rating>) {
    let file = File::open("./day19/input.txt").expect("Open file");
    let lines: std::io::Lines<std::io::BufReader<File>> = std::io::BufReader::new(file).lines();

    let workflows = parse_workflows(&lines);
    let ratings = parse_ratings(&lines);

    (workflows, ratings)
}

fn parse_workflows(lines: &std::io::Lines<std::io::BufReader<File>>) -> HashMap<String, Workflow> {
    for line in lines {
        match line {
            Ok(line_content) => {},
            Err => panic!("Read error"),
        }
    }
}

fn parse_ratings(lines: &std::io::Lines<std::io::BufReader<File>>) -> Vec<Rating> {

}

fn query(workflows: &HashMap<String, Workflow>, rating: &Rating) -> bool {
    // Begin with 'in'
    let mut workflow = workflows.get("in").unwrap();

    loop {
        let res = workflow.query(rating);
        match res {
            WorkflowResult::Accept => return true,
            WorkflowResult::Reject => return false,
            WorkflowResult::Jump(next) => workflow = workflows.get(&next).unwrap(),
        }
    }
}
